package com.hyhy.hycloud.uaa;

import com.hyhy.hycloud.commons.support.MappingMongoConverterConfig;
import org.springframework.context.annotation.*;
import org.springframework.data.redis.connection.RedisConnectionFactory;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.data.redis.serializer.RedisSerializer;
import org.springframework.data.redis.serializer.StringRedisSerializer;

import java.net.UnknownHostException;

/**
 * 应用配置
 *
 * @author Xuegui Yuan
 * @date 2018-09-17
 */
@Configuration
@ImportResource({
        "file:config/dubbo-consumer.xml",
        "classpath*:config/dubbo-consumer.xml"
})
@Import(MappingMongoConverterConfig.class)
@EnableAspectJAutoProxy(exposeProxy = true)
public class ApplicationConfig {

    @Bean
    public RedisTemplate<String, Integer> integerRedisTemplate(RedisConnectionFactory redisConnectionFactory) {
        RedisTemplate<String, Integer> template = new RedisTemplate<>();
        RedisSerializer<String> stringSerializer = new StringRedisSerializer();
        template.setKeySerializer(stringSerializer);
        template.setConnectionFactory(redisConnectionFactory);
        return template;
    }
}
